<!DOCTYPE html>
<ui:composition template="/template/layout.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:p="http://primefaces.org/ui">

	<f:metadata>

		<f:viewAction action="#{contaFinanceiraController.iniciarDados()}" />

	</f:metadata>

	<ui:define name="titulo">Cadastro de Contas Financeiras</ui:define>

	<ui:define name="corpo">

		<h:form id="frm">

			<h3>Cadastro de Contas Financeiras</h3>

			<div class="row-fluid">

				<div class="span12">

					<div class="span2" style="margin-top: 20px;">

						<p:commandButton id="btnNovo" immediate="true" ajax="false" value="Novo" styleClass="btn btn-primary" action="/paginas/conta_financeira/inserir?faces-redirect=true" />

					</div>

					<div class="span3">

						<p:outputLabel value="Situação" />

						<p:selectOneMenu id="idComboboxSituacao" value="#{contaFinanceiraController.formulario.situacaoSelecionada}">

							<f:selectItem itemLabel="Todos" itemValue="NULL" />

							<f:selectItem itemLabel="Ativo" itemValue="ATIVO" />

							<f:selectItem itemLabel="Inativo" itemValue="INATIVO" />

							<p:ajax event="change" update="dtTableContasFinanceiras" listener="#{contaFinanceiraController.pesquisar()}" />

						</p:selectOneMenu>

					</div>
					
					<div class="span7"></div>

				</div>

			</div>

			<div class="row-fluid">

				<div class="span12" style="margin-top: 10px;">

					<p:dataTable value="#{contaFinanceiraController.formulario.listagemContaFinanceira}" var="item" border="1" cellspacing="0" cellpadding="2" paginator="true" rows="5" paginatorPosition="bottom"
						emptyMessage="Nenhum resultado!" lazy="true" id="dtTableContasFinanceiras"
						paginatorTemplate=" {CurrentPageReport} {RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
						currentPageReportTemplate="#{message['label.mostrando']} {startRecord} #{message['label.ate']} {endRecord} #{message['label.de']} {totalRecords} #{message['label.encontrados']}">

						<p:column headerText="Código" width="100" style="text-align: center" sortBy="#{item.id}">
							<h:outputText value="#{item.id}" />
						</p:column>

						<p:column headerText="Nome" sortBy="#{item.nomeContaFinanceira}" filterBy="#{item.nomeContaFinanceira}">
							<h:outputText value="#{item.nomeContaFinanceira}" />
						</p:column>

						<p:column headerText="Observação" sortBy="#{item.observacao}" filterBy="#{item.observacao}">
							<h:outputText value="#{item.observacao}" />
						</p:column>
						
						<p:column headerText="Saldo" sortBy="#{item.saldo}">
							<h:outputText value="#{item.saldo}">
                                <f:convertNumber pattern="#{contaFinanceiraController.formatoValorReal}"/>
                            </h:outputText>
						</p:column>	

						<p:column headerText="Data Cadastro" style="text-align: center" sortBy="#{item.dataCadastro}">
							<h:outputText value="#{item.dataCadastro}">
								<f:convertDateTime pattern="#{usuarioController.formatoData}" timeZone="#{usuarioController.timeZone}" />
							</h:outputText>
						</p:column>

						<p:column headerText="Ações" width="100" style="text-align: center;">

							<p:button icon="ui-icon-pencil" title="Editar" outcome="/paginas/conta_financeira/inserir">
								<f:param name="id" value="#{item.id}" />
							</p:button>

							<p:commandButton rendered="#{item.statusEntidade.status}" icon="ui-icon-closethick" title="Desativar" process="@this" update="@form"
								action="#{contaFinanceiraController.desativarContaFinanceira()}">
								<f:setPropertyActionListener value="#{item}" target="#{contaFinanceiraController.formulario.consulta}" />
								<p:confirm header="Confirmação" message="Confirma a Desativação?" icon="ui-icon-alert" />
							</p:commandButton>

							<p:commandButton rendered="#{!item.statusEntidade.status}" icon="ui-icon-check" title="Ativar" process="@this" update="@form" action="#{contaFinanceiraController.ativarContaFinanceira()}">
								<f:setPropertyActionListener value="#{item}" target="#{contaFinanceiraController.formulario.consulta}" />
								<p:confirm header="Confirmação" message="Confirma a Ativação?" icon="ui-icon-alert" />
							</p:commandButton>

							<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
								<center>
									<p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
									<p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
								</center>
							</p:confirmDialog>

						</p:column>

					</p:dataTable>

				</div>

			</div>

		</h:form>
		
	</ui:define>
	
</ui:composition>